Free online tool

Free Online CSS Gradient Generator

Design linear, radial and conic gradients with colour stops, angles and presets, copy clean CSS and download a PNG that matches the preview.

CSS Gradient GeneratorFree online tool. Runs in your browser.
Live

A gradient is a smooth blend between two or more colours, and CSS can draw one without any image file. That makes backgrounds light, sharp at every screen size and easy to change. Writing the code by hand is fiddly, though: angles, positions and percentages all have to line up. This generator lets you choose the colours, drag the settings, see the result straight away and copy tidy code.

Three kinds of gradient

Type How it blends Settings
Linear Along a straight line Angle, 0 to 360 degrees
Radial Outward from a centre point Circle or ellipse, centre position
Conic Around a point like a colour wheel Start angle, centre position

For a linear gradient, 0 degrees runs from bottom to top, 90 degrees from left to right, 180 from top to bottom and 270 from right to left. Intermediate angles run diagonally. Radial and conic gradients can be centred on the middle, an edge or a corner.

How to use it

  1. Start from a preset such as Violet sky or Ice glow, or leave the default.
  2. Choose the type, and set the angle, shape or centre point.
  3. Edit each colour stop: pick the colour, type its hex code and set its position from 0 to 100 percent.
  4. Add up to ten stops, reverse the order, or press Random for ideas.
  5. Copy the CSS, or download a 1920 by 1080 PNG.

A worked example

The default gradient has three stops, #5A28C8 at 0 percent, #4A6EDD at 55 percent and #46D3DC at 100 percent, at an angle of 135 degrees. The code is linear-gradient(135deg, #5A28C8 0%, #4A6EDD 55%, #46D3DC 100%), usually written as background-image. The generator also writes a plain background colour using the first stop, which older browsers use if they do not understand gradients. Moving the middle stop from 55 to 30 percent shifts the blue towards the start of the blend.

Thinking about colour stops

Each stop is a colour pinned to a position. Between two stops the browser blends smoothly. If two stops share the same position, you get a hard edge, which is how stripes are made. Positions can be in any order while you edit, and the output is sorted for you so that the code always reads from start to end. Choose colours that are close in brightness for a calm blend, or far apart for drama.

Safe output

Only six-digit hexadecimal colours are accepted for stops, and positions and angles are converted to numbers within their ranges. That means the generated code can contain nothing but a gradient, so it is safe to paste into a style sheet, even if your input came from somewhere else. A typed code that is not valid is simply ignored.

Downloading a PNG

The PNG button draws the gradient onto a canvas, using the same geometry as CSS, and saves it as a picture. We compared the saved pictures with the browser’s own rendering of the CSS for linear, circular, elliptical and conic gradients, and the average difference was under one level out of 255. Conic gradients on a canvas need a recent browser; if yours cannot draw them, the tool says so and you can use the CSS instead.

Design tips

  • Put readable text over the calmest part of the gradient, and check the contrast.
  • Use two or three colours; many stops can look muddy.
  • Pick colours that sit close together on the colour wheel for natural blends.
  • Use a darker end for depth, or a lighter end for a glow.
  • Test on a phone, because small screens show less of the blend.

Limits

The tool covers the common single gradient and does not make repeating gradients, layered backgrounds, transparency stops or colour interpolation settings. Blends are drawn in the default colour space of the browser, and slightly different results may appear between browsers or between a screen and a print. The built-in presets use the colour palette of this site; you can change them to anything.

Look up or convert any stop with the colour converter, find matching colours with the colour palette generator, and test the code in the playground. The guide on designing social media posts shows gradients in use, and the CSS course teaches backgrounds and layout properly.

Using the code in a page

Paste the two lines into the rule for the element you want to style, such as a hero section, a button or the body of the page. Give the element a height, because a gradient only fills the space an element already has. For text over a gradient, add a dark or light overlay if the colours vary a lot. If the gradient is purely decorative, make sure the information in your page does not depend on it.

Key takeaways

  • CSS gradients are light, sharp at any size and easy to edit.
  • Linear uses an angle, radial a centre and shape, conic a start angle and centre.
  • Two stops at the same position make a hard edge.
  • Only valid hex colours reach the code, so the output is safe to paste.
  • The PNG download is drawn to match the CSS preview.

Questions

How do I make a CSS gradient?

Choose the type, set the angle or centre, and pick two or more colours with positions. The generator writes the code, such as linear-gradient(135deg, #5A28C8 0%, #46D3DC 100%), which you copy into a style sheet as background-image. It also shows a live preview so you can adjust until it looks right.

What do the angles mean in a linear gradient?

Zero degrees draws from bottom to top, ninety degrees from left to right, one hundred and eighty from top to bottom and two hundred seventy from right to left. Other values tilt the line in between. The colours blend along that line, and 135 degrees gives a common top-left to bottom-right look.

How do I get a hard edge or stripes?

Place two colour stops at the same position. For example, a stop of one colour at 50 percent followed by another colour at 50 percent produces a sharp boundary instead of a blend. Repeating that pattern with several stops makes stripes. The generator sorts stops by position so the code stays correct.

Why does the PNG look slightly different from the preview?

It should match closely, because the same geometry is used, and our tests found an average difference below one level out of 255. Small differences can come from the browser colour handling. If the match matters, use the CSS in your design, since it will be drawn by the same engine as the rest of the page.

Can I use transparency in the stops?

Not in this tool. It accepts six-digit hex colours only, which keeps the output safe and simple. To add transparency, copy the code and change a colour to an rgba or eight-digit hex value by hand, or use a fully transparent stop in your own style sheet after testing it.